package com.tth.learn.addproperties.java;

import org.junit.Test;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * @Author tth
 * @Date 2022/12/27 16:34
 */
public class PathTest {

    @Test
    public void test() {
        Path path = Paths.get("D:\\project\\JavaSenior\\day10\\image.png");
        String str = path.toString();
        System.out.println("toString(): "+str);

        boolean startsWith = path.startsWith("D:\\project");
        boolean endsWith = path.endsWith("image.png");
        System.out.println("startsWith: " + startsWith);
        System.out.println("endsWith: " + endsWith);

        boolean absolute = path.isAbsolute();
        System.out.println("isAbsolute: " + absolute);

        System.out.println("getParent: " + path.getParent());
        System.out.println("getRoot: " + path.getRoot());
        System.out.println("getFileName: " + path.getFileName());
        System.out.println("getNameCount:" + path.getNameCount());
        System.out.println("getName(index): " + path.getName(1));
        System.out.println("toAbsolutePath: " + path.toAbsolutePath());
        System.out.println("resolve: " + Paths.get("D:\\project\\").resolve(Paths.get("JavaSenior\\day10")));
        System.out.println("toFile: " + path.toFile());

    }
}
